package com.sanyang.lawyer.service.Audit;

import com.sanyang.lawyer.ResultApi.ResponseResult;
import com.sanyang.lawyer.entity.Audit;
import com.sanyang.lawyer.entity.Audit_type;
import com.sanyang.lawyer.entity.Case_audit;
import com.sanyang.lawyer.entity.System_user;
import com.sanyang.lawyer.mapper.audit.AuditMapper;
import com.sanyang.lawyer.utils.RedisUtils;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class AuditService {
    
    @Autowired
    private AuditMapper auditMapper;
    
    @Autowired
    private RedisUtils redisUtils;
    

    //添加一条数据
    public void insertOne(String processid, Case_audit audit){
        //设置数据
        Audit insertAudit = new Audit();
        insertAudit.setAuditid(processid);
        insertAudit.setSubmitTime(new Date());
        insertAudit.setSubmitid(audit.getAuditid().getSubmitid());
        insertAudit.setRemark(audit.getAuditid().getRemark());
        insertAudit.setState("未审核");
        
        Audit_type type = new Audit_type();
        type.setTypeid(1);
        
        insertAudit.setTypeid(type);
        auditMapper.insertOne(insertAudit);
    }
    
    //完成流程并添加数据
    public void ComplateInsert(Audit audit){
        //设置审核时间，审核人，审核评论，是否通过
        audit.setAuditTime(new Date());
        auditMapper.ComplateInsert(audit);
    }
    
    
    //修改流程审核的状态
    public void update_state(Audit audit){
        auditMapper.update_state(audit);
    }

    
    //根据流程id查询出流程的审批记录
    public List<Audit> findProcessListByProcessid(String processid){
        return auditMapper.findProcessListByProcessid(processid);
    }

    public List<Audit> listall(){
        return auditMapper.listall();
    }
    

    //用印统计
    public List<Map<String,Object>> listStatistical(Map map){
        return auditMapper.listStatistical(map);
    }
    public Integer listcount(Map map){return  auditMapper.listcount(map);}
}
